import {create,findMany,updateOne,deleteOne,createPic,findPicMany,updateOnePic,uploadFile,deleteFile,findFileMany} from "../services/dic";

export default {
  namespace: 'dic',
  state: {},
  effects: {
    * create({payload}, {call, put}) {
      const response = yield call(create, payload);
      return response;
    },
    * findMany({payload}, {call, put}) {
      const response = yield call(findMany, payload);
      return response;
    },
    * updateOne({payload}, {call, put}) {
      const response = yield call(updateOne, payload);
      return response;
    },
    * deleteOne({payload}, {call, put}) {
      const response = yield call(deleteOne, payload);
      return response;
    },
    * createPic({payload}, {call, put}) {
      const response = yield call(createPic, payload);
      return response;
    },
    * findPicMany({payload}, {call, put}) {
      const response = yield call(findPicMany, payload);
      return response;
    },
    * updateOnePic({payload}, {call, put}) {
      const response = yield call(updateOnePic, payload);
      return response;
    },
    * uploadFile({payload}, {call, put}) {
      const response = yield call(uploadFile, payload);
      return response;
    },
    * deleteFile({payload}, {call, put}) {
      const response = yield call(deleteFile, payload);
      return response;
    },
    * findFileMany({payload}, {call, put}) {
      const response = yield call(findFileMany, payload);
      return response;
    },

  },
  reducers: {
    onDataLoad(state, {payload}) {
      state._notify = undefined;
      return {...state, ...payload};
    },
    onNotify(state, {payload}) {
      console.log('notifyyy',payload)
      state._notify = payload;
      return {...state, ...payload}
    }
  },

};
